package com.ljm.sys.auth.controller;

import com.ljm.common.dto.BaseResult;
import com.ljm.common.util.ResultUtil;
import com.ljm.sys.auth.api.SysAuthUserRoleApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
    * 系统用户角色关联 前端控制器
    * </p>
 *
 * @author HuamingChen
 * @since 2019-02-25
 */
@Api(description="系统用户角色关联")
@Controller
@RequestMapping("/auth/sysAuthUserRole")
public class SysAuthUserRoleController {

    /**
    * 系统用户角色关联接口
    */
   @Resource
    private SysAuthUserRoleApi sysAuthUserRoleApi;

    @ApiOperation(value="分页获取系统用户角色关联")
    @GetMapping(value = "/getByPage")
    @ResponseBody
    public BaseResult getByPage(@ApiParam(value="角色code") @RequestParam String roleCode,
                                @ApiParam(value="账号") @RequestParam(required = false) String loginName,
                                @ApiParam(value="真实名称") @RequestParam(required = false) String realName,
                                @ApiParam(value="邮箱") @RequestParam(required = false) String email,
                                @ApiParam(value="页码") @RequestParam Integer pageNo,
                                @ApiParam(value="页大小") @RequestParam Integer pageSize){
        return ResultUtil.successData(sysAuthUserRoleApi.getRefUserByPage(roleCode,loginName,realName,email,pageNo,pageSize));
    }

    @ApiOperation(value = "删除角色用户关联")
    @PostMapping(value = "/del")
    @ResponseBody
    public BaseResult del(@ApiParam(value = "主键") @RequestBody List<Long> ids) {
        sysAuthUserRoleApi.bathDel(ids);
        return ResultUtil.success();
    }
}
